<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8"/>
	<link id="easyuiTheme" rel="stylesheet" type="text/css" href="../jquery-easyui-1.5.3/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../jquery-easyui-1.5.3/themes/icon.css"/>
    <!--<link rel="stylesheet" type="text/css" href="../jquery-easyui-1.5.3/demo/demo.css"/> -->
    <script type="text/javascript" src="../jquery-easyui-1.5.3/jquery.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.5.3/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../jquery-easyui-1.5.3/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript">
	    var contextPath = function() {
	        return  "/" + location.pathname.split("/")[1];
	    }
	    
		function getValue(name){
			var str=window.location.search;
			if (str.indexOf(name)!=-1){
				var pos_start=str.indexOf(name)+name.length+1;
				var pos_end=str.indexOf("&",pos_start);
				if (pos_end==-1){
					return str.substring(pos_start);
				} else {
					return str.substring(pos_start,pos_end);
				}
			} else {
				return "";
			}
		}
		
		var themeName = getValue("theme");
		if (themeName!=""){
		    var cssurl  = $('#easyuiTheme').attr('href');  
		    var href = cssurl.substring(0, cssurl.indexOf('themes')) + 'themes/' + themeName + '/easyui.css';  
		    $('#easyuiTheme').attr('href', href);  
		}   
		
	    //将表单数据转为json
	    function form2Json(id) {
	        var arr = $("#" + id).serializeArray();
	        var jsonStr = "";
	        jsonStr += '{';
	        for (var i = 0; i < arr.length; i++) {
	            jsonStr += '"' + arr[i].name + '":"' + arr[i].value + '",'
	        }
	        jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
	        jsonStr += '}';
	        var json = JSON.parse(jsonStr);
	        return json;
	    }
	    
	    //将表单数据转为json格式的字符串，当然也可以JSON.stringify(data)
	    function form2JsonStr(id) {
	        var arr = $("#" + id).serializeArray();
	        var jsonStr = "";
	        jsonStr += '{';
	        for (var i = 0; i < arr.length; i++) {
	            jsonStr += '"' + arr[i].name + '":"' + arr[i].value + '",'
	        }
	        jsonStr = jsonStr.substring(0, (jsonStr.length - 1));
	        jsonStr += '}';
	        return jsonStr;
	    }
	</script>

</head>

<style>
    .datagrid-btable{
        width:100%;
    }
    .datagrid-header-inner{
        width:100%;
    }
    .datagrid-header{
        width:100%;
    }
    .datagrid-htable{
        width:100%;
    }
    .datagrid-cell{margin:auto;}
    .fitem{text-align:center}
    .ftitle{text-align:center}
</style>

<body>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',title:''">	  
        <table id="datagrid"  class="easyui-datagrid" style="width:100%;height:100%"></table>
    </div>
</div>
</body>

<script type="text/javascript">

    $(function() {
    	var paramData = getValue('data');
    	paramData = JSON.parse(decodeURIComponent(paramData));
    	$('#datagrid').datagrid({
    		loadMsg:'正在加载数据...',
    	    url:contextPath()+'/mdmis/countReceiptRateByArea',
    	    //toolbar:'#dgtoolbar',
    	    queryParams: paramData,
            rownumbers: true,
            striped: true, //隔行显示颜色
            fit: true,
            fitColumns: false, //不自动适应列宽
            singleSelect: true, 
            sortName: 'receipt_rate',
            sortOrder: 'desc', //默认值是 'asc'
            remoteSort: false,
            loader: function(param, success, error) {
            	$.ajax({
            		type : $(this).datagrid("options").method,
            		url : $(this).datagrid("options").url,
            		dataType : 'json',
            		contentType : 'application/json;charset=utf-8', // 设置请求头信息
            		data : JSON.stringify(param),
            		success : function(result) {
            			//alert(result.data);
            			success(result);
            		}
            	});
            },
            rowStyler:function(index,row){
    			if (row.area=='广西汇总'){
    				return 'background-color:#B0C4DE;color:#4169E1;font-weight:bold;';
    			}
    		},
    	    columns:[[
    			{field:'area',title:'地区',sortable:true,align:'center',width:100,
					formatter: function(value,row,index){
				        if (value=='广西汇总') {
							return paramData["project"];    
				        } else {
				            return value;
				        }
					}	
				},
    			{field:'receipt_rate',title:'回销率',sortable:true,align:'right',width:100,
    				formatter: function(value,row,index){
    			        if (value) {
    			        	if (value==0){
    			        		return "0%";
    			        	} else {
        			        	return value.toFixed(5)*100 + "%";    			        		
    			        	}
    			        } else {
    			            return "0%";
    			        }
    				}	
    			},
    			{field:'total',title:'总件数',sortable:true,align:'right',width:100},
    			{field:'send',title:'寄送中',sortable:true,align:'right',width:100},
    			{field:'receipt',title:'已回销',sortable:true,align:'right',width:100},
    			{field:'backall',title:'已退回',sortable:true,align:'right',width:100},
    			{field:'intro',title:'已收未寄',sortable:true,align:'right',width:100},
    			{field:'unintro',title:'未到广西',sortable:true,align:'right',width:100},
    			{field:'withdrawal',title:'已撤件',sortable:true,align:'right',width:100},
    			{field:'surrender',title:'已退保',sortable:true,align:'right',width:100},
    	    ]]
    	});      	
    	  
    });
 
</script>


</html>



